<template>
  <!-- 添加或修改订单提成记录对话框 -->
  <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" v-dialogDrag>
    <el-row :gutter="10">
      <el-col :span="24">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>订单信息</span>
          </div>
          <el-descriptions class="margin-top " :contentStyle="CS" :label-style="LS" title="" :column="2" size="medium" border>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                订单名称
              </template>
              {{form.order.name || ''}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-money"></i>
                所属地区
              </template>
              <dict-tag :options="dict.type.order_area" :value="form.order.area"/>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                订单编号
              </template>
              {{form.order.code}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-c-scale-to-original"></i>
                开票日期-回款日期
              </template>
              {{form.order.invoicingTime}}~{{form.order.endDate}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-bank-card"></i>
                回款天数
              </template>
              {{form.returnDays}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-c-scale-to-original"></i>
                订单金额
              </template>
              {{form.order.contractMoney}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-bank-card"></i>
                提成比例
              </template>
              {{form.percent}}%
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-bank-card"></i>
                提成金额
              </template>
            {{form.money}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-bank-card"></i>
                业务员
              </template>
              {{form.salesmanName}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-bank-card"></i>
                备注
              </template>
              {{form.remark}}
            </el-descriptions-item>
          </el-descriptions>
        </el-card>
      </el-col>
    </el-row>

    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {getAction, addAction, getById, updateAction, accMul, accDiv, accSub} from '@/api/manage';
import moment from 'moment';

export default {
  name: "orderCommissionRecordDetail",
  dicts: ['order_area'],
  data() {
    return {
      title:'',
      // 遮罩层
      loading: true,
      activeName: "first",
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      order: {},
      rule: {},
      // 表单校验
      rules: {},
      url: {
        getById: '/orderCommissionRecord/orderCommissionRecord/',
        getByOrderId: '/orderCommissionRecord/orderCommissionRecord/getByOrderId/',
      },
      CS: {
        'text-align': 'center',  //文本居中
        'min-width': '250px',   //最小宽度
        'word-break': 'break-all'  //过长时自动换行
      },
      LS: {
        'color': '#000',
        'text-align': 'center',
        'font-weight': '600',
        'height': '40px',
        'min-width': '110px',
        'word-break': 'keep-all'
      }
    };
  },
  created() {

  },
  methods: {
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        orderId: null,
        salesmanId: null,
        salesmanName: null,
        returnDays: null,
        orderMoney: null,
        ruleId: null,
        percent: null,
        money: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null
      };
      this.resetForm("form");
    },

    handleShowByOrderId(row) {
      this.reset();
      this.open = true;
      this.order = row;
      this.title = "订单提成记录详情";
      getAction(this.url.getByOrderId+row.id, {}).then(response => {
        this.form = response.data;
        console.log(this.form);
        this.open = true;
      });
    },

    handleShowById(row) {
      this.reset();
      this.open = true;
      this.order = row;
      this.title = "订单提成记录详情";
      getById(this.url.getById, row.id).then(response => {
        this.form = response.data;
        this.open = true;
      });
    },

  }
};
</script>
